// ++++++++++++++++++++++++++++++++++++++++
// 《零基础Go语言算法实战》源码
// ++++++++++++++++++++++++++++++++++++++++
// Author:廖显东（ShirDon）
// Blog:https://www.shirdon.com/
// Gitee:https://gitee.com/shirdonl/goAlgorithms.git
// Buy link :https://item.jd.com/14101229.html
// ++++++++++++++++++++++++++++++++++++++++

package main

import "fmt"

type Node struct {
	Data int
	Next *Node
}

func (n *Node) AddNode(data int) {
	newNode := Node{data, nil}

	for n.Next != nil {
		n = n.Next
	}
	n.Next = &newNode
}

func (n *Node) Print() {
	for n != nil {
		fmt.Println(n.Data)
		n = n.Next
	}
}

func main() {
	newNode := Node{1, nil}
	newNode.AddNode(6)
	newNode.AddNode(8)
	newNode.AddNode(99)
	newNode.Print()
}

//$ go run linkList1.go
//1
//6
//8
//99
